using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using System.IO;
namespace Easislides
{
	public class FrmSplashScreen : Form
	{
		private IContainer components = null;
		private Label labelVersion;
		private Label labelUser;
		private Panel panel1;
		private System.Windows.Forms.Timer TimerCheckClose;
		private Label labelCopyright;
		private static Thread _splashLauncher;
        private PictureBox picBox1;
		private static FrmSplashScreen _splashScreen;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.labelVersion = new System.Windows.Forms.Label();
            this.labelUser = new System.Windows.Forms.Label();
            this.panel1 = new System.Windows.Forms.Panel();
            this.picBox1 = new System.Windows.Forms.PictureBox();
            this.labelCopyright = new System.Windows.Forms.Label();
            this.TimerCheckClose = new System.Windows.Forms.Timer(this.components);
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.picBox1)).BeginInit();
            this.SuspendLayout();
            // 
            // labelVersion
            // 
            this.labelVersion.BackColor = System.Drawing.Color.Transparent;
            this.labelVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.labelVersion.ForeColor = System.Drawing.Color.MediumBlue;
            this.labelVersion.Location = new System.Drawing.Point(9, 243);
            this.labelVersion.Name = "labelVersion";
            this.labelVersion.Size = new System.Drawing.Size(166, 29);
            this.labelVersion.TabIndex = 1;
            this.labelVersion.Text = "Version 4";
            this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // labelUser
            // 
            this.labelUser.BackColor = System.Drawing.Color.Transparent;
            this.labelUser.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.labelUser.ForeColor = System.Drawing.Color.RoyalBlue;
            this.labelUser.Location = new System.Drawing.Point(17, 176);
            this.labelUser.Name = "labelUser";
            this.labelUser.Size = new System.Drawing.Size(368, 67);
            this.labelUser.TabIndex = 3;
            this.labelUser.Text = "User";
            this.labelUser.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.picBox1);
            this.panel1.Controls.Add(this.labelCopyright);
            this.panel1.Controls.Add(this.labelUser);
            this.panel1.Controls.Add(this.labelVersion);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(390, 270);
            this.panel1.TabIndex = 4;
            // 
            // picBox1
            // 
            this.picBox1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.picBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            this.picBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.picBox1.Location = new System.Drawing.Point(0, 0);
            this.picBox1.Name = "picBox1";
            this.picBox1.Size = new System.Drawing.Size(390, 270);
            this.picBox1.TabIndex = 5;
            this.picBox1.TabStop = false;
            // 
            // labelCopyright
            // 
            this.labelCopyright.BackColor = System.Drawing.Color.Transparent;
            this.labelCopyright.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.labelCopyright.ForeColor = System.Drawing.Color.MediumBlue;
            this.labelCopyright.Location = new System.Drawing.Point(197, 243);
            this.labelCopyright.Name = "labelCopyright";
            this.labelCopyright.Size = new System.Drawing.Size(190, 29);
            this.labelCopyright.TabIndex = 4;
            this.labelCopyright.Text = "Copyright";
            this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // TimerCheckClose
            // 
            this.TimerCheckClose.Enabled = true;
            this.TimerCheckClose.Interval = 500;
            this.TimerCheckClose.Tick += new System.EventHandler(this.TimerCheckClose_Tick);
            // 
            // FrmSplashScreen
            // 
            this.ClientSize = new System.Drawing.Size(390, 270);
            this.ControlBox = false;
            this.Controls.Add(this.panel1);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FrmSplashScreen";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.panel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.picBox1)).EndInit();
            this.ResumeLayout(false);

		}
		public FrmSplashScreen()
		{
			this.Cursor = Cursors.AppStarting;
			this.InitializeComponent();
			base.Width = 400;
			base.Height = 280;
			this.labelVersion.Text = "Version: 4.0.5";
			this.labelCopyright.Text = '©'.ToString() + " 2003-2010 Wai Kuen Mo";
			this.labelUser.Text = "Congtt";gf.Trim(gf.GetRegValue("config", "RegistrationUser", ""));
			base.TopMost = false;
            string text=Application.StartupPath + "\\Backgrounds\\SplashScreen"; 
            if (Directory.Exists(text))
            {
                picBox1.ImageLocation = text+"\\sp_Dove.jpg";
            }
		}
		public static void ShowSplash()
		{
			FrmSplashScreen._splashLauncher = new Thread(new ThreadStart(FrmSplashScreen.LaunchSplash));
			FrmSplashScreen._splashLauncher.IsBackground = true;
			FrmSplashScreen._splashLauncher.Start();
		}
		private static void LaunchSplash()
		{
			FrmSplashScreen._splashScreen = new FrmSplashScreen();
			Application.Run(FrmSplashScreen._splashScreen);
		}
		private static void CloseSplashDown()
		{
			Application.ExitThread();
		}
		public static void CloseSplash()
		{
			MethodInvoker method = new MethodInvoker(FrmSplashScreen.CloseSplashDown);
			FrmSplashScreen._splashScreen.Invoke(method);
		}
		private void TimerCheckClose_Tick(object sender, EventArgs e)
		{
			if (gf.SplashScreenBack)
			{
				this.SplashBack(true);
			}
			if (gf.SplashScreenFront)
			{
				this.SplashBack(false);
			}
			if (gf.SplashScreenCanClose)
			{
				FrmSplashScreen.CloseSplash();
			}
		}
		private void SplashBack(bool Min)
		{
			if (Min)
			{
				base.SendToBack();
			}
			else
			{
				base.BringToFront();
			}
			gf.SplashScreenBack = false;
			gf.SplashScreenFront = false;
		}
	}
}
